package xjtu.sad.zbsj.service.impl;

import org.springframework.stereotype.Service;
import xjtu.sad.zbsj.dao.task.TCreditDao;
import xjtu.sad.zbsj.entity.TCredit;
import xjtu.sad.zbsj.service.TCreditService;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TCredit)表服务实现类
 *
 * @author makejava
 * @since 2021-12-04 01:55:27
 */
@Service("tCreditService")
public class TCreditServiceImpl implements TCreditService {
    @Resource
    private TCreditDao tCreditDao;

    /**
     * 通过ID查询单条数据
     *
     * @param userId 主键
     * @return 实例对象
     */
    @Override
    public TCredit queryById(Integer userId) {
        return this.tCreditDao.queryById(userId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<TCredit> queryAllByLimit(int offset, int limit) {
        return this.tCreditDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tCredit 实例对象
     * @return 实例对象
     */
    @Override
    public TCredit insert(TCredit tCredit) {
        this.tCreditDao.insert(tCredit);
        return tCredit;
    }

    /**
     * 修改数据
     *
     * @param tCredit 实例对象
     * @return 实例对象
     */
    @Override
    public TCredit update(TCredit tCredit) {
        this.tCreditDao.update(tCredit);
        return this.queryById(tCredit.getUserId());
    }

    /**
     * 通过主键删除数据
     *
     * @param userId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer userId) {
        return this.tCreditDao.deleteById(userId) > 0;
    }


}
